from selenium import webdriver
from selenium.webdriver import ActionChains
import time

# 建立浏览器实例
browser = webdriver.Chrome()
# 打开网址
browser.get('http://localhost:8080/login')
# 获取用户名输入框
input_kuang = browser.find_element_by_id('username')
input_kuang.send_keys('123')
time.sleep(1)
# 获取密码输入框
input_kuang = browser.find_element_by_id('password')
input_kuang.send_keys('123')
action = ActionChains(browser)
# 找到移动的滑块
source = browser.find_element_by_xpath('//*[@id="app"]/div/section/div/center/div/div/div[3]')
action.click_and_hold(source).perform()  # 鼠标左键按下不放
action.move_by_offset(259, 0)  # 需要滑动的坐标
action.release().perform()  # 释放鼠标
time.sleep(2)
# 找到登录按钮并点击
browser.find_element_by_id('button').click()
time.sleep(2)
# 关闭浏览器
browser.quit()
